package com.mtl.inmigrant.shoes.entity;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import android.content.SharedPreferences;

import com.mtl.inmigrant.shoes.ActivitiesFromGPlusHelper;

public class ActionPageHelper {
	
	
	private static List<ActivityPage> activitiesPage; 
	private static List<TaskPage> taskPages;
	private static  List<ReferentialPage> referentialPages ;

	
	
	
	public static void createListActionsFromPage(SharedPreferences preferences) throws IOException{
		
		List<String> allActionFromPage =  ActivitiesFromGPlusHelper.getGooglePlusActivitiesImmigrant(preferences);
		activitiesPage = new ArrayList<ActivityPage>();
		taskPages = new ArrayList<TaskPage>();
		referentialPages = new ArrayList<ReferentialPage>();
		
		/*
		allActionFromPage.add("A1:GET NAS");
		allActionFromPage.add("A1-T1:FIND SERVICE CANADA");
		allActionFromPage.add("A1-T1-R1:Service Canada centre ville");
		allActionFromPage.add("A1-T1-R2:Service Canada villerey");
		
		allActionFromPage.add("A1-T2:CHECK DOCUMENTS");*/
		
		if(allActionFromPage!=null && allActionFromPage.size()>0){
		
			for(int u=0; u < allActionFromPage.size(); u++){
			
				String itemFromPage= allActionFromPage.get(u);
				int countTire = 0;
				
				countTire = UtilityShoesEntityApp.countC(itemFromPage, '-');
				
				if(countTire ==0){
				
					ActivityPage actPage = new ActivityPage();
					
					actPage.setIdActivity(UtilityShoesEntityApp.getStringFromAction(itemFromPage,"onlyId",0));
					actPage.setNameActivity(UtilityShoesEntityApp.getStringFromAction(itemFromPage,"onlyName",0));		
					
					activitiesPage.add(actPage);

				
				}else if(countTire == 1){
					
					TaskPage taskPage = new TaskPage();
					
					taskPage.setIdTask(UtilityShoesEntityApp.getStringFromAction(itemFromPage,"onlyId",0));
					taskPage.setNameTask(UtilityShoesEntityApp.getStringFromAction(itemFromPage,"onlyName",0));
					
					taskPages.add(taskPage);
				
				}else if(countTire == 2){
					
					ReferentialPage referPage = new ReferentialPage();
					
					referPage.setIdReferential(UtilityShoesEntityApp.getStringFromAction(itemFromPage,"onlyId",0));
					referPage.setName(UtilityShoesEntityApp.getStringFromAction(itemFromPage,"onlyName",0));
					
					referentialPages.add(referPage);
					
				}
				
			}
		
				setActivitiesPage(activitiesPage);
				setTaskPages(taskPages);
				setReferentialPages(referentialPages);
			}	
		
	}




	public static List<ActivityPage> getActivitiesPage() {
		return activitiesPage;
	}




	public static void setActivitiesPage(List<ActivityPage> activitiesPage) {
		ActionPageHelper.activitiesPage = activitiesPage;
	}




	public static List<TaskPage> getTaskPages() {
		return taskPages;
	}




	public static void setTaskPages(List<TaskPage> taskPages) {
		ActionPageHelper.taskPages = taskPages;
	}




	public static List<ReferentialPage> getReferentialPages() {
		return referentialPages;
	}




	public static void setReferentialPages(List<ReferentialPage> referentialPages) {
		ActionPageHelper.referentialPages = referentialPages;
	}
	
	
	
	
	


	
	

}
